package com.ferry.lock.engine;

import com.ferry.lock.config.engine.EngineConfig;
import com.ferry.lock.lock.IReentrantLock;
import com.ferry.lock.lock.IReentrantReadWriteLock;
import com.ferry.lock.lock.impl.ReentrantReadWriteLock;

/**
 * Created by daiyong
 */
public interface LockEngine {

	/**
	 * 初始化
	 * @param engineConfig
	 * @return
	 */
	boolean init(EngineConfig engineConfig);

	/**
	 * 销毁
	 */
	void destroy();

	/**
	 * 获取重入锁
	 * @param name
	 * @return
	 */
	IReentrantLock getReentrantLock(String name);

	/**
	 * 获取重入锁
	 * @param name
	 * @return
	 */
	IReentrantLock getReentrantLock(String name, int expireTime);

	/**
	 * 获取重入锁
	 * @param name
	 * @return
	 */
	IReentrantLock getReentrantLock(String name, int expireTime, int retry);

	/**
	 * 获取读写锁
	 * @param name
	 * @return
	 */
	IReentrantReadWriteLock getReentrantReadWriteLock(String name);

	/**
	 * 获取读写锁
	 * @param name
	 * @return
	 */
	IReentrantReadWriteLock getReentrantReadWriteLock(String name, int expireTime);

	/**
	 * 获取读写锁
	 * @param name
	 * @return
	 */
	IReentrantReadWriteLock getReentrantReadWriteLock(String name, int expireTime, int retry);

	/**
	 * 是否初始化
	 * @return
	 */
	boolean isInitialized();

	void setInitialized(boolean initialized);

	String getName();

	void setName(String name);

	Object getProcessor();

}
